<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>Document</title>
</head>

<body>
  <script>
    //不绑定this，从作用域链的上一层继承 this，此外var声明的变量会挂在全局对象上，思考若为let会输出什么
    var name = 'global name';
    const test = {
      name: 'object name',
      plainFunction: function () {
        let fn = function(){
            console.log(this.name);
        }
        fn();
      },
      arrowFunction: function () {
        let fn = () => {
          console.log(this.name);
        };
        fn();
      },
    };
    test.plainFunction();//global name
    test.arrowFunction();//object name
  </script>
</body>

</html>